@extends('backstage.layout.master')
@section('title', '素材上传')
@section('style')
        <!-- page specific plugin styles -->
{{--<link rel="stylesheet" href="css/dropzone/dropzone.css" />--}}
<link rel="stylesheet" href="/assets/css/dropzone.css" />
<!-- fonts -->
@stop
@section('content')
    <style>
        #dropzone{
            padding-top: 15px;
            padding-left:30px;
            padding-right:30px;
        }
        .alert-info {
            color: #ad0002;
        }
    </style>
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a target="_blank" href="backstage/home">主页</a>
            </li>

            <li class="active">
                <a target="_blank" href="/backstage/source-pic/all">素材</a>
            </li>
            <li>
                素材上传
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        素材
                        <small>
                            <i class="icon-double-angle-right"></i>
                            素材上传
                        </small>
                        <span class="pull-right">
                          <button class="btn btn-primary" onclick="javascript:window.location.href='{{asset('')}}backstage/source-pic/get-source-pic-by-tag?id={{isset($tag->id)?$tag->id:0}}';"><i class="icon-undo bigger-110"></i>当前标签素材列表</button>
                         <button class="btn btn-primary" onclick="javascript:window.location.href='{{asset('')}}backstage/source-pic/all';"><i class="icon-undo bigger-110"></i>返回素材列表</button>
                         <button class="btn btn-primary" onclick="javascript:window.location.href='{{asset('')}}backstage/source-pic/source-pic-tag-list';"><i class="icon-undo bigger-110"></i>返回标签列表</button>
                        </span>
                    </h1>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <h3 class="header smaller lighter red">标签简介：</h3>
                        <div class="well">
                            <h4 class="green smaller lighter">标签参数</h4>
                            1、标签编号：{{isset($tag->id)?$tag->id:""}}</br>
                            2、标签名：{{isset($tag->tag_name)?$tag->tag_name:""}}</br>
                            3、有无绑定子标签：
                            @if(isset($tag->has_sub_tag)&&($tag->has_sub_tag==1))
                                有
                            @elseif(isset($tag->has_sub_tag)&&($tag->has_sub_tag===0))
                                无
                                @else
                                @endif
                                </br>
                                4、当前标签是否获取全部素材：
                                @if(isset($tag->tag_type)&&($tag->tag_type==1))
                                    是
                                @else
                                    不是
                                    @endif
                                    </br>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="alert alert-info">
                            <i class="icon-hand-right"></i>
                            统一定价添加:&nbsp
                            <select>
                                <option selected value="price">定价</option>
                            </select>
                            <input type="number" id="price" name="price" min=0 step=0.01 value=0>
                        </div>

                        <div id="dropzone">
                            <form action="/backstage/source-pic/bluk-add-source-pic" class="dropzone">
                                <input type="hidden" class="price" name="price" min=0 step=0.01 value=0>
                                <input type="hidden"  name="tag_id"  value="{{isset($tag_id)?$tag_id:0}}">
                                <input type="hidden" name="upload_type" value=1>
                                <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                                <div class="fallback">
                                    <input name="file" type="file" multiple="" />
                                </div>
                            </form>
                        </div><!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    {{--<script src="js/dropzone/dropzone.js"></script>--}}
    <script src="/js/dropzone/dropzone.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
    try {
        $('#price').change(function() {
            var price=$(this).val();
            $('.price').val(price);
        });
    $(".dropzone").dropzone({
    paramName: "file", // The name that will be used to transfer the file
    maxFilesize: 10, // MB

    addRemoveLinks : true,
    dictDefaultMessage :
    '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> Drop files</span> to upload \
    <span class="smaller-80 grey">(or click)</span> <br /> \
    <i class="upload-icon icon-cloud-upload blue icon-3x"></i>'
    ,
    dictResponseError: '上传文件过程中发生错误!',

    //change the previewTemplate to use Bootstrap progress bars
    previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n  <div class=\"dz-details\">\n    <div class=\"dz-filename\"><span data-dz-name></span></div>\n    <div class=\"dz-size\" data-dz-size></div>\n    <img data-dz-thumbnail />\n  </div>\n  <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n  <div class=\"dz-success-mark\"><span></span></div>\n  <div class=\"dz-error-mark\"><span></span></div>\n  <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
    sending: function(file, xhr, formData) {
            formData.append("filesize", file.size);
        },
    success: function (file, response, e) {
            if (response.state!='M00000') {
                $(file.previewTemplate).children('.dz-error-mark').css('opacity', '1');
                file.previewElement.classList.add("dz-error");
                $(file.previewElement).find('.dz-error-message').text(response.message);
            }else {
                file.previewElement.classList.add("dz-success");
                $(file.previewTemplate).children('.dz-success-mark').css('opacity', '1');
            }
    }
    });
    } catch(e) {
    alert('当前浏览器版本太低，插件不支持此浏览器!');
    }

    });
    </script>
@stop